<html>

<head>
    <script type="text/javascript" >
    </script>
</head>

<body>
    <div id="parentDiv">
        <div id="div1">安全的div</div>
        <div id="div2">即将被删除的div</div>
    </div>
    <button onclick="removeDiv()">删除第二个div</button>

    <script type="text/javascript">
        // xmlDoc = loadXMLDoc("/example/xdom/books.xml");

        // newel = xmlDoc.createElement("edition");

        // x = xmlDoc.getElementsByTagName("book")[0];
        // x.appendChild(newel);

        // document.write(x.getElementsByTagName("edition")[0].nodeName);



        // 删除节点
        function removeDiv() {
            var parentDiv = document.getElementById("parentDiv");
            var div2 = document.getElementById("div2");
            parentDiv.removeChild(div2);
        }
    </script>
</body>

</html>